<?php

use App\Http\Controllers\AdminController;
use App\Http\Controllers\ApiController;
use App\Http\Middleware\AdminAuth;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Admin\Agent;
use App\Http\Controllers\Admin\Level;
use App\Http\Controllers\Admin\Order;
use App\Http\Controllers\Admin\With;
use App\Http\Controllers\Admin\Stat;
use App\Http\Controllers\Admin\Channel;
use App\Http\Controllers\Admin\Good;
use App\Http\Controllers\Admin\Service;
use App\Http\Controllers\Admin\Recharge;
use App\Http\Controllers\Admin\Set;
use App\Http\Controllers\AgentController;
use App\Http\Controllers\Admin\Bill;

/*
 |--------------------------------------------------------------------------
 | Web Routes
 |--------------------------------------------------------------------------
 |
 | Here is where you can register web routes for your application. These
 | routes are loaded by the RouteServiceProvider within a group which
 | contains the "web" middleware group. Now create something great!
 |
 */

Route::middleware(AdminAuth::class)->prefix('SPAdmin')->group(function () {
    Route::any('/login',[AdminController::class,'login'])->withoutMiddleware(AdminAuth::class);
    Route::any('/',[Stat::class,'index']);
    Route::any('/stat',[Stat::class,'index']);
    Route::any('/bill',[Bill::class,'index']);
    Route::prefix('/agent')->group(function(){
        Route::any('/',[Agent::class,'index']);
        Route::post('/post',[Agent::class,'post']);
        Route::post('/credit',[Agent::class,'credit']);
        Route::post('/del',[Agent::class,'del']);
    });
    Route::prefix('/service')->group(function(){
        Route::any('/',[Service::class,'index']);
        Route::post('/post',[Service::class,'post']);
        Route::post('/del',[Service::class,'del']);
    });
    Route::prefix('/channel')->group(function(){
        Route::any('/',[Channel::class,'index']);
        Route::post('/post',[Channel::class,'post']);
        Route::post('/del',[Channel::class,'del']);
    });
    Route::prefix('/good')->group(function(){
        Route::any('/',[Good::class,'index']);
        Route::post('/post',[Good::class,'post']);
        Route::post('/del',[Good::class,'del']);
        Route::post('/bind',[Good::class,'bind']);
        Route::post('/cate',[Good::class,'cate']);
    });
    Route::prefix('/level')->group(function(){
        Route::any('/',[Level::class,'index']);
        Route::post('/post',[Level::class,'post']);
    });
    Route::prefix('/set')->group(function(){
        Route::any('/',[Set::class,'index']);
        Route::post('/post',[Set::class,'post']);
    });
    Route::prefix('/recharge')->group(function(){
        Route::any('/',[Recharge::class,'index']);
    });
    Route::prefix('/order')->group(function(){
        Route::any('/',[Order::class,'index']);
        Route::post('/refund',[Order::class,'refund']);
        Route::post('/reback',[Order::class,'reback']);
        Route::get('/export',[Order::class,'export']);
        Route::post('/resubmit',[Order::class,'resubmit']);
    });
    Route::prefix('/with')->group(function(){
        Route::any('/',[With::class,'index']);
        Route::post('/agree',[With::class,'agree']);
        Route::post('/order',[With::class,'order']);
    });
});
Route::any('/reg/{code}', [AgentController::class, 'reg']);
Route::post('/notify/{ordersn}', [ApiController::class, 'notify']);
Route::post('/channelnotify/{type}/{ntype}', [ApiController::class, 'channelnotify']);
Route::get('/channelprice', [ApiController::class, 'channelprice']);
Route::get('/{code?}', [AdminController::class, 'app']);